Python 程式內相關的參數調整
python 程式內部有一些相關的參數可以調整:
# Please configure the following settings for your environment
MQTT_SERVER = "gpssensor.ddns.net" #伺服器位址
MQTT_PORT = 1883 #伺服器連接阜
MQTT_ALIVE = 90 #連接Timeout的時間
MQTT_TOPIC = "LASS/Test/#" #訂閱的主題開頭 '#'代表全部的任意字串
SERIALPORT="/dev/ttyS0" #所使用的Serial port名稱
BUADRATE=57600 #LinkitSmart 7688 Duo Serial1 端的 buadrate
################################################################
接下來要執行這隻程式,指令如下:
python lass-pm25-friend.py [你的站號] [你的ThingspeakAPI key] [模式]
其中模式 0 是只使用thingspeak(原本的功能)、1是只使用Serial、2是兩種功能都使用,執行後的畫面如下:
Trying To Connect:gpssensor.ddns.net
MQTT Connected with result code 0
Got your MQTT channel
LASS/Test/PM25|ver_format=3|fmt_opt=0|app=PM25|ver_app=0.7.13|device_id=FT1_004|tick=378198422|date=2016-01-22|time=15:01:45|device=LinkItONE|s_0=69813.00|s_1=100.00|s_2=1.00|s_3=0.00|s_4=692.00|s_d0=27.00|s_t0=20.10|s_h0=75.30|s_d1=28.00|gps_lat=23.284026|gps_lon=120.275832|gps_fix=1|gps_num=16|gps_alt=6
為了讓每次通電開機時,都能夠自動啟動這一隻程式,先將啟動語法複製好設定在 /etc/rc.local/ 之下,你必須先輸入指令:
chmod 777 /etc/rc.local
vim /etc/rc.local
並在VIM中編輯如下:
python /root/lass_pm25_friend.py [FT1_ID] [APIKEY] 2 >lasslog.out &